package sn.gandal.mobile.kalpet.adaptators;

import java.util.HashMap;
import java.util.Map;

import sn.gandal.mobile.kalpet.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;

public class TextViewAdapter extends BaseAdapter {
	
	private Context context;
	public static int[] textViews={
								   R.id.tvGestionA,R.id.tvGestionB, R.id.tvGestionC, 
								   R.id.tvGestionV, R.id.tvGestionH, R.id.tvServices
								   };
	static final String[] numbers = new String[] { 
		"Gestion Achats", "Gestion Bons", "Gestion Comptes", "Gestion Ventes",
		"Gestion Historiques", "Mes Services",
		};
	private final Map<Integer,String> maps=new HashMap<Integer, String>();
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return textViews.length;
	}
	public TextViewAdapter(Context context){
		this.context=context;
		initMaps();
	}
	
	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		TextView tv;
		if(convertView !=null){
			tv=(TextView)convertView;
		}else{
		    tv=new TextView(context);
		    tv.setLayoutParams(new GridView.LayoutParams(80,80));
		    tv.setGravity(Gravity.CENTER);
		    tv.setTextSize(12);
		    tv.setTextColor(Color.WHITE);
		    //tv.setPadding(8, 8, 8, 8);
		   // tv.setTextColor(android.c);
		}
		
		tv.setText(maps.get((Integer)textViews[position])); // numbers[position]);
		return tv;
	}
	
	private void initMaps() {
		// TODO Auto-generated method stub
		maps.put(textViews[0], numbers[0]);
		maps.put(textViews[1], numbers[1]);
		maps.put(textViews[2], numbers[2]);
		maps.put(textViews[3], numbers[3]);
		maps.put(textViews[4], numbers[4]);
		maps.put(textViews[5], numbers[5]);
	}

}
